<?php
/**
 * FIFSKY - The most easy-to-use PHP MVC framework
 * http://blog.chibaole.com
 *
 * Copyright (c) 2009 fifsky(蔡旭东)
 * Licensed under the GPL licenses.
 *
 * @author fifsky<fifsky@gmail.com>
 * @version $Id: index.php 77 2009-12-05 06:57:10Z fifsky $
 */
//检查php版本
if(version_compare(PHP_VERSION,'5.0.0','<') ) die('Require PHP > 5.0 !');

!defined('DS')			&& define('DS', DIRECTORY_SEPARATOR);
!defined('BASE_ROOT')	&& define('BASE_ROOT', dirname(dirname(__FILE__)));
!defined('APP_DIR')		&& define('APP_DIR', basename(dirname(__FILE__)));

require(BASE_ROOT . DS . APP_DIR . DS. 'config' . DS . 'config.php');
require(BASE_ROOT . DS . APP_DIR . DS. 'config' . DS . 'database.php');

$config['debug'] ? error_reporting(E_ALL) : error_reporting(0);
header ( "Content-type: text/html;charset={$config['CharSet']}");
@date_default_timezone_set($config['TimeZone']);

//生成htaccess文件
if ($config['UrlReWrite']) {
	is_file(BASE_ROOT . DS . '.htaccess') || file_put_contents(BASE_ROOT . DS . '.htaccess', "# BEGIN Rewrite\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . index.php [L]\r\n</IfModule>\r\n# END Rewrite", LOCK_EX);
	is_file(BASE_ROOT . DS . APP_DIR . DS . '.htaccess') || file_put_contents(BASE_ROOT . DS . APP_DIR . DS . '.htaccess', "# BEGIN Rewrite\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . index.php [L]\r\n</IfModule>\r\n# END Rewrite", LOCK_EX);
} else {
	is_file(BASE_ROOT . DS . '.htaccess') && unlink(BASE_ROOT . DS . '.htaccess');
	is_file(BASE_ROOT . DS . APP_DIR . DS . '.htaccess') && unlink(BASE_ROOT . DS . APP_DIR . DS . '.htaccess');
}
//不进行魔术过滤
@set_magic_quotes_runtime(0);

require BASE_ROOT . DS . 'fifsky' . DS . 'libs'. DS . 'bootstrap.php';